import java.io.*;

/**
 * @author: wh(1835734390 @ qq.com)
 * @date: 2022/10/13 11:28
 * @description:
 * @version:
 */
public class BufferedReaderTest02 {
    public static void main(String[] args) throws Exception{

        // 字节流
        FileInputStream in = new FileInputStream("copy");

        // 通过转换流转换（InputStreamReader将字节流转换成字符流。）
        // in是节点流。reader是包装流。
        InputStreamReader reader = new InputStreamReader(in);

        // 这个构造方法只能传一个字符流。不能传字节流。
        // reader是节点流。br是包装流。
        BufferedReader br = new BufferedReader(reader);

        // 合并
        //BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("Copy02.java")));

        String line = null;
        while((line = br.readLine()) != null){
            System.out.println(line);
            System.out.println("\n");
        }

        // 关闭最外层
        br.close();
    }

    public static void main2(String[] args) throws Exception{
        // 带有缓冲区的字符输出流
        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("copy", true)));
        // 开始写。
        out.write("hello world!");
        out.write("\n");
        out.write("hello kitty!");
        // 刷新
        out.flush();
        // 关闭最外层
        out.close();
    }
}


